package org.zebias.study.netty.boot;

import io.netty.channel.ChannelHandlerContext;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @ClassName ChannelMap
 * @Description 通道存储器
 * @Author zebias
 * @Date 2020/8/18 15:15
 * @Version 1.0
 **/
public class ChannelStore {

    private Map<String, ChannelHandlerContext> map = new ConcurrentHashMap<>(16);

    private ChannelStore() {
    }
    public static ChannelStore channelMap = new ChannelStore();

    public static ChannelStore getInstance() {
            return channelMap;
    }

    public void add(String name,ChannelHandlerContext ctx) {
        map.put(name, ctx);
    }

    public ChannelHandlerContext getCtx(String name) {
        return map.get(name);
    }
}
